#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "utility.hpp"
#include <QAction>
#include <QFontDialog>
#include <QColorDialog>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
//    ui->textEdit->setEnabled(false);

    //进行文件读取操作
    const QString &text = utility::ReadFile("C:/Users/LKM/Code/snake-game/Snake/history/historyScore.txt");
    ui->textEdit->setText(text);

    //对菜单项绑定槽函数
    connect(ui->action_font,&QAction::triggered,[=](){
        bool ok = false;
        QFont font = QFontDialog::getFont(&ok,this);
        ui->textEdit->setFont(font);
    });

    connect(ui->action_color,&QAction::triggered,[=](){
        QColor color = QColorDialog::getColor(Qt::green,this);
        ui->textEdit->setTextColor(color);
    });

}

MainWindow::~MainWindow()
{
    delete ui;
}
